// exam2.摄像头招到多少人
#include <bits/stdc++.h>
using namespace std;

int camera(const vector<string>& maze, int x, int y){
    int cnt = 0;
    // heng
    for(int j=y; j>=0;j--){
        if(maze[x][j]=='B') break;
        if(maze[x][j]=='P') cnt++;
    }
    for(int j=y+1;j<maze[0].size();j++){
        if(maze[x][j]=='B') break;
        if(maze[x][j]=='P') cnt++;
    }
    for(int i=x; i>=0; i--){
      if(maze[i][y]=='B') break;
      if(maze[i][y]=='P') cnt++;
    }
    for(int i=x+1; i<maze.size(); i++){
      if(maze[i][y]=='B') break;
      if(maze[i][y]=='P') cnt++;
    }
    return cnt;
}

int getPeople(vector<string> maze) {
    int maxCnt = 0;
    for(size_t i=0; i<maze.size(); i++){
      for(size_t j=0; j<maze[0].size(); j++){
        if(maze[i][j]=='N'){
          int cur = camera(maze, i,j);
          maxCnt = max(maxCnt, cur);
          printf("===%d,%d\n", cur, maxCnt);
      }
    }
  }
    return maxCnt;
}

int main_mazess(){
  // people,Block,None
  vector<string> vtStr = {
  "NNPP",
  "NNBN",
  "NBNB",
  "PPNN",};
  auto vt2(vtStr);
  cout << getPeople(vtStr) << endl;
}
